﻿using System;
using System.Collections.Generic;
using System.Web.Mvc;

namespace BlueLotus7.Eden.Web
{
    public class AjaxCollection
    {
        private Dictionary<string, List<string>> collection = new Dictionary<string, List<string>>();
        private static AjaxCollection instance = new AjaxCollection();

        public static AjaxCollection Instance { get { return instance; } }

        private AjaxCollection()
        {
            Initialize();
        }

        private void Initialize()
        {
            InitializeArchiveCommon();
            InitializeStatus();
            InitializeWeibo();
            InitializeDomainScope();
        }

        private void InitializeArchiveCommon()
        {
            List<string> ajaxUrls = new List<string>();


            collection.Add("ArchiveCommon", ajaxUrls);
        }

        private void InitializeWeibo()
        {
            List<string> ajaxUrls = new List<string>();


            collection.Add("weibo", ajaxUrls);
        }

        private void InitializeStatus()
        {
            List<string> ajaxUrls = new List<string>();

            ajaxUrls.Add("GetUserListByDomainScopeKey");
            ajaxUrls.Add("MergeStatus");
            ajaxUrls.Add("QueryStatusGridByCriterias");
            ajaxUrls.Add("QueryStatusCalendarByCriterias");            

            collection.Add("status", ajaxUrls);
        }

        private void InitializeDomainScope()
        {
            List<string> ajaxUrls = new List<string>();

            ajaxUrls.Add("AddOrUpdateDomainScope");
            ajaxUrls.Add("AddOrUpdateDomainScopeUser");
            ajaxUrls.Add("QueryDomainScope");
            ajaxUrls.Add("QueryDomainScopeUser");
            ajaxUrls.Add("UpdateIMNeedMonitor");
            

            collection.Add("domainscope", ajaxUrls);
        }

        public List<string> GetAjaxCollectionByControllerName(string controllerName)
        {
            List<string> result = new List<string>();

            if (!string.IsNullOrWhiteSpace(controllerName))
            {
                controllerName = controllerName.ToLowerInvariant();
                if (collection.ContainsKey(controllerName))
                {
                    result = collection[controllerName];
                }
            }

            return result;
        }
    }
}
